import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

class AlertDialogDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('AlertDialog'),
        centerTitle: true,
      ),
      body: Center(
        child: FlatButton(
          color: Colors.blue,
          textColor: Colors.white,
          child: Text('点击提示'),
          onPressed: () {
            createDialog(context);
          },
        ),
      ),
    );
  }

  createDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            //标题
            title: Text('拨打电话'),
            //标题内边距
            titlePadding: EdgeInsets.all(10),
            //标题样式
            titleTextStyle: TextStyle(
                fontSize: 18, color: Colors.black, ),
            //内容
            content: SingleChildScrollView(
              child: Container(
                child: Column(
                  children: <Widget>[
                    Text('是否拨打电话18339995599'),
                  ],
                ),
              ),
            ),
            //内容样式
            contentTextStyle: TextStyle(fontSize: 15, color: Colors.grey[800]),
            //按钮
            actions: [
              RaisedButton(
                  color: Colors.white,
                  child: Text(
                    '取消',
                    style: TextStyle(fontSize: 16, color: Colors.blue),
                  ),
                  onPressed: () {
                    Navigator.of(context).pop();
                  }),
              RaisedButton(
                  color: Colors.white,
                  child: Text(
                    '确定',
                    style: TextStyle(fontSize: 16, color: Colors.blue),
                  ),
                  onPressed: () {
                    Navigator.of(context).pop();
                    launch("tel://18339995599");
                  }),
            ],
          );
        });
  }
}
